package cn.stylefeng.guns.modular.gridsystem.temperature.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.guns.core.exception.ServiceException;
import cn.stylefeng.guns.core.factory.PageFactory;
import cn.stylefeng.guns.core.pojo.page.PageResult;
import cn.stylefeng.guns.modular.gridsystem.temperature.entity.BizTemperatureChannel;
import cn.stylefeng.guns.modular.gridsystem.temperature.entity.BizTemperatureException;
import cn.stylefeng.guns.modular.gridsystem.temperature.entity.BizTemperatureExceptionLog;
import cn.stylefeng.guns.modular.gridsystem.temperature.mapper.BizTemperatureChannelMapper;
import cn.stylefeng.guns.modular.gridsystem.temperature.mapper.BizTemperatureExceptionLogMapper;
import cn.stylefeng.guns.modular.gridsystem.temperature.model.param.BizTemperatureExceptionLogParam;
import cn.stylefeng.guns.modular.gridsystem.temperature.model.param.BizTemperatureExceptionParam;
import cn.stylefeng.guns.modular.gridsystem.temperature.model.result.BizTemperatureExceptionLogResult;
import cn.stylefeng.guns.modular.gridsystem.temperature.model.result.BizTemperatureExceptionResult;
import cn.stylefeng.guns.modular.gridsystem.temperature.service.BizTemperatureChannelService;
import cn.stylefeng.guns.modular.gridsystem.temperature.service.BizTemperatureExceptionLogService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class BizTemperatureExceptionLogServiceImpl extends ServiceImpl<BizTemperatureExceptionLogMapper, BizTemperatureExceptionLog> implements BizTemperatureExceptionLogService {
    @Override
    public PageResult<BizTemperatureExceptionLogResult> pageList(BizTemperatureExceptionLogParam param) {
        Page<BizTemperatureExceptionLogResult> page = this.baseMapper.page(PageFactory.defaultPage(), param);
        return new PageResult<>(page);
    }

    @Override
    public void del(BizTemperatureExceptionParam param) {
        BizTemperatureExceptionLog bizTemperatureExceptionLog = this.getById(param.getId());
        if (ObjectUtil.isEmpty(bizTemperatureExceptionLog)) {
            throw new ServiceException("删除的内容不存在！");
        }
        this.removeById(param.getId());

    }
}
